//
//  LYBadgeBtn.m
//  artist
//
//  Created by Jay_Apple on 16/4/21.
//  Copyright © 2016年 viviyoo. All rights reserved.
//

#import "LYBadgeBtn.h"
#import "UIImage+Image.h"
#import "UIImage+XMGExtension.h"

@interface LYBadgeBtn ()

@property (nonatomic , weak) UIImageView *badgeView;

@end


@implementation LYBadgeBtn

- (instancetype)initWithCoder:(NSCoder *)aDecoder{

    if (self = [super initWithCoder:aDecoder]) {
        [self setUpBadge];
    }
    return self;
}


- (instancetype)initWithFrame:(CGRect)frame{


    if (self = [super initWithFrame:frame]) {
        [self setUpBadge];
    }
    
    return self;
}


- (void)setUpBadge{

    //badge
    UIImage *badgeImage = [UIImage imageWithColor:[UIColor colorWithHexString:LYHomeNavBadgeColor alpha:1.0] andSize:CGSizeMake(LYHomeNavBadgeWH, LYHomeNavBadgeWH)];
    badgeImage = [badgeImage circleImage];
    UIImageView *badgeView = [[UIImageView alloc] initWithImage:badgeImage];
    [badgeView sizeToFit];
    [self addSubview:badgeView];
    self.badgeView = badgeView;
    [self hideBadge];

}

- (void)layoutSubviews{

    [super layoutSubviews];
    
    self.badgeView.center = CGPointMake(self.My_Width, 0);
    
}


- (void)showBadge{
    
    self.badgeView.hidden = NO;

}

- (void)hideBadge{

    self.badgeView.hidden = YES;
}

@end
